package entity;
/*
   农作物: 父类
 */
public abstract class Crop {
    private String name;   //名称
    private int growTime;        //生长期
    private int harvestTime;      //采摘期
    private int numsOfFruits;   //果实数量
    private String status;   //生长状态   生长期  、采摘期、死亡期
    private boolean isHarvested;  //是否采摘

    public Crop() {
        System.out.println("农作物 出生");
    }

    public Crop(String name) {
        this.name = name;

    }

    public Crop(String name, int growTime, int harvestTime, int numsOfFruits, String status, boolean isHarvested) {
        this.name = name;
        this.growTime = growTime;
        this.harvestTime = harvestTime;
        this.numsOfFruits = numsOfFruits;
        this.status = status;
        this.isHarvested = isHarvested;
    }

    /*
       abstract: 抽象的
       抽象方法
       1. 被 abstract 修饰的方法就是抽象方法 没有方法体
       2. 抽象方法必须在抽象类中
       3. 被abstract 修饰的类就是抽象类
       4. 抽象方法一定要被子类重写
       5. 因为抽象类不能实例化，所以不能创建对象
     */
    public abstract void print();

    public void printGrowReport() {
        System.out.println(this.getName() + "处于:" + this.getStatus());
    }

    public void harvest() {
        //在采摘期可以收获果实
        if (getStatus().equals("采摘期")) {
            if (!this.isHarvested()) {
                System.out.println("收获果实" + this.getNumsOfFruits() + "个");
                this.setHarvested(true);//设置为已采摘
            } else {
                System.out.println("果实已采摘!!");
            }
        } else {
            System.out.println("抱歉目前没有果实可以采摘");
        }
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getGrowTime() {
        return growTime;
    }

    public void setGrowTime(int growTime) {
        this.growTime = growTime;
    }

    public int getHarvestTime() {
        return harvestTime;
    }

    public void setHarvestTime(int harvestTime) {
        this.harvestTime = harvestTime;
    }

    public int getNumsOfFruits() {
        return numsOfFruits;
    }

    public void setNumsOfFruits(int numsOfFruits) {
        this.numsOfFruits = numsOfFruits;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean isHarvested() {
        return isHarvested;
    }

    public void setHarvested(boolean harvested) {
        isHarvested = harvested;
    }
}
